<?php
/* 监控要求  monitor */
class OperatorModel extends BaseModel
{
	var $table  = 'operator';
	var $prikey = 'o_tid';
	var $_name  = 'operator';

	var $_relation = array(

	//一个用户有多个运单异常
	 
	);

	/*
	 * 判断名称是否唯一
	 */
	function unique($o_code, $o_name, $id)
	{

		if ($id!=''){
			$sql="SELECT 1 FROM zys_operator WHERE o_code='".$o_code."'  AND o_tid <> ".$id."";
			 
			$sqltwo="SELECT 1 FROM zys_operator WHERE o_name='".$o_name."'  AND o_tid <> ".$id."";
			 

			if ($this->getOne($sql)>0){
				return 2;
			}elseif ($this->getOne($sqltwo)>0){
				return 1;
			}
		}elseif ($id=='') {
			$sql="SELECT 1 FROM zys_operator WHERE o_code='".$o_code."'";
			 
			$sqltwo="SELECT 1 FROM zys_operator WHERE o_name='".$o_name."'";

			if ($this->getOne($sql)>0){
				return 2;
			}elseif ($this->getOne($sqltwo)>0){
				return 1;
			}
		}
	}

	function  getoperatorId($o_code){
	   $sql="SELECT o_tid FROM zys_operator WHERE o_code='".$o_code."'";
			return $this->getOne($sql);
	}


}
?>
